#!/usr/bin/env node

//类
const Koa = require('koa'),
      Router = require('koa-router');

const app = new Koa();
const router = new Router();

app.use((ctx,next)=>{ //M-logger

  console.log(`${ctx.method} ${ctx.path}`);
  next();
  
});

router.prefix('/api/authors');

  router.get('/', async (ctx)=>{
    ctx.body = '查询漫画书';
  })

  router.get('/:authorName/', async(ctx)=>{
    ctx.body='按名字查询漫画书';
  })

  router.post('/',async(ctx)=>{
    ctx.body = '添加新的漫画书';
  })

  router.put('/:id', async(ctx)=>{
    ctx.body = '修改';
  })

  router.delete('/:id',async(ctx)=>{
    ctx.body='删除';
  })

app.use(router.routes());

app.listen(8080);

